#ifndef _RECHARGE_NET_H
#define _RECHARGE_NET_H

#include "sgl_types.h"
#include "recharge_config.h"

#define NET_SUCCESS		 1
#define NET_FAILURE		 0

/**
 * \brief command handler
 *
 * \param evt the command events
 * \param pResult the result node for the response
 */

/**
 * \brief Initialize the Recharge network component
 *
 * \return ??
 */
void Account_ShowNetErrorMsg(void);

int32 Account_netMsgInit(void);

int Net_GetSmsConfig_PackSend(uint32 value , int32 pacageid , PCSTR pcTime);

int Net_GetSmsConfig_Unpack(int32 totalSize, int32 pBuf, int32 bufLen);

int Net_DepostitBySms_PackSend(RECHARGE_PSMSRES pstSmsRes);

int Net_DepostitBySms_Unpack(int32 totalSize, int32 pBuf, int32 bufLen);

int Net_GetBalance_PackSend(void);

int Net_DepostitByCard_PackSend(int32 value ,  PCWSTR cardNumber , PCWSTR cardPassword , 
								PCSTR cardtype,PCSTR savetype,PCSTR pmid,PCSTR pcid ,PCSTR currency);
int Net_DepostitByCard_Unpack(int32 totalSize, int32 pBuf, int32 bufLen);

int Net_GetBalance_Unpack(int32 totalSize, int32 pBuf, int32 bufLen);

VOID RechargeNet_SendSMS(void);

BOOL RechargeNet_Initialize(VOID);

int32 NetGetUserInfoReq(void);

int32 NetGetAccountInfoReq(void);

int32 NetSetUserInfoReq(BYTE gender, BYTE blood, PCWSTR nick, int16 iyear, int16 month, int16 day,
						PCWSTR fullName, PCWSTR homeTown, PCWSTR address, PCWSTR summary);
/**
 * \brief Send command to server
 *
 * \param url the request url
 * \param pData the post data if has, NULL when there is no data
 * \param size the data size in bytes
 * \param timeout the command timeout interval
 * \param handler the command events handler
 * \return ??
 */
PSTR RechargeNet_EncodeSMS(PCSTR command, PCSTR TransationID,int32 order_count, int32 total, int32 index);

/**
 * \brief Dispatch the Recharge commands result
 *
 * \param pData the response data from server
 * \param size the data size in bytes
 * \return ???
 */
BOOL RechargeNet_DispatchCommand(PCSTR pData, int size);

/**
 * \brief Handle the network error
 * 
 * \param err the error message
 * \return ???
 */
BOOL RechargeNet_Error(DWORD err);
/**
 * \brief show a msgbox to notify the bad network response
 */
VOID RechargeNet_BadCommandResponse(VOID);

/**
 * \brief default getRechargeConfig command handler
 *
 * \param evt the Recharge net events
 * \param pResult the pointer to result node
 */
VOID RechargeNet_OnGetRechargeConfig(DWORD evt, VOID* pResult);

/**
 * \brief send the "getRechargeConfig" command to server
 *
 * \param handler the command handler
 * \return ???
 */

/**
 * \brief default getBalance command handler for recharge
 *
 * \param evt the Recharge net events
 * \param pResult the pointer to result node
 */
VOID RechargeNet_OnGetBalance(DWORD evt, VOID* pResult);

/**
 * \brief send the "getBalance" command to server
 *
 * \param unit the currency type
 * \param handler the command events handler
 * \return ??
 */
//BOOL RechargeNet_GetBalance(DWORD unit, Recharge_command_handler handler);
int32 RechargeNet_GetBalance(void);

/**
 * \brief default fillByCard command handler
 * 
 * \param evt the Recharge net events
 * \param pResult the pointer to result node
 */
VOID RechargeNet_OnFillByCard(DWORD evt, VOID* pResult);

/**
 * \brief send the "fillByCard" command to server
 *
 * \param type the provider type
 * \param area the card area type
 * \param card the card id
 * \param pwd the password  for the card
 * \param amount the card amount
 * \param handler the event command handler
 * \return ??
 */
int32 RechargeNet_FillByCard(int32 value,PCWSTR card, PCWSTR pwd, PCSTR cardType,
							 PCSTR saveType, PCSTR pmid, PCSTR pcid ,PCSTR currency);
/**
 * \brief default consume command handler
 * \param evt the Recharge net event
 * \param pResult the result xml node
 */
VOID RechargeNet_OnConsume(DWORD evt, VOID* pResult);

/**
 * \brief buy some thing
 *
 * \param p_id the product id
 * \param unit the currency type
 * \param amount how much the product cost
 * \param handler the command handler
 * \return TRUE on success, FALSE otherwise
 */

/**
 * \brief 
 */
VOID RechargeNet_OnFillBySMS(DWORD evt, VOID* pResult);

/**
 * \brief
 */
int RechargeNet_FillBySMS(VOID);

/**
 * \brief 
 */
/**
 * \brief
 */
int Net_SynChannel_PackSend(void);
int32 NetRegister( char* pcUserName,  char* pcPassWord);
int32 NetRegisterQuick(VOID);
int32 NetLogin(char* pcUserName, char* pcPassWord , BOOL bAutoLogin);
int32 NetModify( char* pcOldPassWord,  char* pcNewPassWord);
int32 NetLoginOut(uint32 skyid , uint32 token);
int32 NetSetSecretQ(PCSTR pcSecretQ, PCSTR pcSecretA);
int32 NetSetSecretQUnPack(int32 totalSize, int32 pBuf, int32 bufLen);
int32 NetGetSecretQ(PCSTR pcUserName, PCSTR pcMobileNumber);
int32 NetGetSecretQUnPack(int32 totalSize, int32 pBuf, int32 bufLen);
int32 NetResetPwd(PCSTR pcUserName, PCSTR pcMobileNumber, PCSTR pcSecretQ, PCSTR pcSecretA);
int32 NetResetPwdUnPack(int32 totalSize, int32 pBuf, int32 bufLen);
int32 NetSetUserName(PCSTR pcNewUserName);
int32 NetSetUserNameUnPack(int32 totalSize, int32 pBuf, int32 bufLen);
int32 NetModifyUnPack(int32 totalSize, int32 pBuf, int32 bufLen);
int32 NetRegistUnPack(int32 totalSize, int32 pBuf, int32 bufLen);
int32 NetLoginUnPack(int32 totalSize, int32 pBuf, int32 bufLen);
uint8* passwdEncode(char* pwd);
int32 NetGetHistory(PCSTR stday, PCSTR edday , BOOL isRate , int32 ModeId);
int32 NetPayReqPackSend(uint32 appId, uint32 bussinessId, uint32 nativePrice, 
						char* exchangePwd, char* type, char* appName, 
						char* bussinessName, char* accountType);

int32 NetGetNewMail(void);
#endif
